package com.project.controller;

import com.common.annotation.Log;
import com.common.core.controller.BaseController;
import com.common.core.domain.AjaxResult;
import com.common.core.page.TableDataInfo;
import com.common.enums.BusinessType;
import com.project.domain.entity.BizProjectCooperationUnit;
import com.project.service.IProjectCooperationUnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目合作单位Controller
 * 
 * @author baige
 * @date 2025-02-08
 */
@RestController
@RequestMapping("/system/unit")
public class ProjectCooperationUnitController extends BaseController
{
    @Autowired
    private IProjectCooperationUnitService bizProjectCooperationUnitService;

    /**
     * 查询项目合作单位列表
     */
//    @PreAuthorize("@ss.hasPermi('system:unit:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizProjectCooperationUnit bizProjectCooperationUnit)
    {
        startPage();
        List<BizProjectCooperationUnit> list = bizProjectCooperationUnitService.selectBizProjectCooperationUnitList(bizProjectCooperationUnit);
        return getDataTable(list);
    }

    /**
     * 获取项目合作单位详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:unit:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(bizProjectCooperationUnitService.selectBizProjectCooperationUnitByID(ID));
    }

    /**
     * 新增项目合作单位
     */
//    @PreAuthorize("@ss.hasPermi('system:unit:add')")
    @Log(title = "项目合作单位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizProjectCooperationUnit bizProjectCooperationUnit)
    {
        return toAjax(bizProjectCooperationUnitService.insertBizProjectCooperationUnit(bizProjectCooperationUnit));
    }

    /**
     * 修改项目合作单位
     */
//    @PreAuthorize("@ss.hasPermi('system:unit:edit')")
    @Log(title = "项目合作单位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizProjectCooperationUnit bizProjectCooperationUnit)
    {
        return toAjax(bizProjectCooperationUnitService.updateBizProjectCooperationUnit(bizProjectCooperationUnit));
    }

    /**
     * 删除项目合作单位
     */
//    @PreAuthorize("@ss.hasPermi('system:unit:remove')")
    @Log(title = "项目合作单位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(bizProjectCooperationUnitService.deleteBizProjectCooperationUnitByIDs(IDs));
    }
}
